<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/pages/login/common.jsp" %>
<%
String path = request.getContextPath();
%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta content="B2B电商平台" name="description"/>
<meta content="B2B电商平台" name="keyword"/>

<title>B2B电商平台.车辆信息维护</title>
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/global.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/btn.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/themes.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/proManage.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/page.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/mmt_trading.css" />
<link rel="stylesheet" type="text/css" href="<%=path%>/include/pagination/page.css" media="all">
<link rel="stylesheet" type="text/css" href="<%=path %>/include/sweetalert/sweetalert.css" />
<script type="text/javascript" src="<%=path %>/include/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.common.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/cookies.js"></script>
<script type="text/javascript" src="<%=path%>/include/pagination/jquery.pagination.js"></script>
<script type="text/javascript" src="<%=path%>/include/pagination/init.js"></script>
<script type="text/javascript" src="<%=path %>/include/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript" src="<%=path %>/include/sweetalert/sweetalert-dev.js"></script>

<style type="text/css">
#listTable td{
  font-size:12px;
  border: 1px solid #ddd;
  padding: 4px;
}
input{border-radius: 4px;}
h2{
width:480px;
}
.noborder{border:none;height:2px;overflow:hidden;}
.noborder td{height: 2px;}
#listTable th{
   border: 1px solid #ddd;
   font-weight: bold;
  
}
.saveButton{
    width:44px;
    height:24px;
    line-height:24px;   
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: 0 -203px;
    border:0;
    cursor:pointer;
    font: 12px/1.5 arial,tahoma,\5b8b\4f53;
    margin: 0 0 0 5px;
    outline:none;
    background-image: url('<%=path%>/include/css/img/xs_bgx.png');   
}
</style>
<script type="text/javascript">
	$(function(){
		_queryList();
	})
	//查询车辆信息列表
	var pagination;
	function _queryList(){
		var url = "<%=path %>/vehicleInfo/queryVehicleList.do";
		var data = {
			carNo : $("#carNo").val()
		};
  		pagination = _initPagination({'pageId':'pagination', 'cKey':'toVehicleList','url': url,'data': data,'rows': 10, 'callback':_initDataList});
	}
	function _initDataList(data) {
	 		var d = data.rows;
	 		var total = data.total;
			var str = "";
			$("#list_tbody").empty();
			for(var i=0;i<d.length;i++){
				str += "<tr class='list_table_tr'>";
				str += "    <td class='span5' style='text-align:center;vertical-align: middle'>"+d[i].PID+"</td>";
				str += "    <td class='span10' style='text-align:center;vertical-align: middle'>"+d[i].CAR_NAME+"</td>";
				str += "    <td class='span10' style='text-align:center;vertical-align: middle'>"+d[i].CAR_NO+"</td>";
				str += "    <td class='span15' style='text-align:right;vertical-align: middle'>"+d[i].CAR_COLOR+"</td>";
				if(d[i].STATUS=='1'){
					str += "    <td class='span10' style='text-align:center;vertical-align: middle'>启用</td>";
				}else{
					str += "    <td class='span10' style='text-align:center;vertical-align: middle;color:#CD0000;'>停用</td>";
				}
				str +=" 	<td  style='width:20%;text-align:center;vertical-align: middle;padding:1px;'>";
				if(d[i].STATUS=='1'){
					str +="    		<a href='javaScript:void(0);' onclick=\"_dealStatus('" + d[i].CAR_UUID +"','0')\" >停用</a>";
				}else{
					str +="    		<a href='javaScript:void(0);' onclick=\"_dealStatus('" + d[i].CAR_UUID +"','1')\" >启用</a>";
					str +="    		/&nbsp;<a href='javaScript:void(0);' onclick=\"_editVehicle('" + d[i].CAR_UUID +"')\" >修改</a>";
					str +="    		/&nbsp;<a href='javaScript:void(0);' onclick=\"_deleteVehicle('" + d[i].CAR_UUID +"')\" >删除</a>";
				}
				str +=" 	</td>";
				str +=" </tr>";
			}
			if(str == ''){
				str += "<tr>";
				str += "	<td colspan='6' style='text-align:center'>暂无数据</td>";
				str += "</tr>";
			}
			$("#list_tbody").append(str);
			_reHeight("rightFrame", "contentDiv");
	 }
	 //添加车辆信息
	 function _addVehicle(){
		window.location.href = '<%=path%>/vehicleInfo/editVehicle.do?operat=add';
	 }
	//修改车辆信息		
	function _editVehicle(carUuid){
		window.location.href = '<%=path%>/vehicleInfo/editVehicle.do?operat=edit&carUuid=' + carUuid;
	}
	//删除车辆信息
	function _deleteVehicle(carUuid){
		parent.swal({
			title: "确定删除吗？", 
			type: "warning",
			showCancelButton: true,
			closeOnConfirm: false,
			cancelButtonText: "取消",
			cancelButtonColor: "#ec6c62",
			confirmButtonText: "确定",
			confirmButtonColor: "#ec6c62"
			}, function() {
				$.ajax({
	                cache: true,
	                type: "POST",
	                url:'<%=path%>/vehicleInfo/deleteVehicle',
	                data:{
	                	carUuid:carUuid
	                },
	                async: false,
	                error: function(request) {
	                    parent.swal("", msg, "删除失败!");
	                },
	                success: function(data) {
	                	data = eval('(' + data + ')');
						var msg = data.msg;
	                    if(data.success){
	                     	location.reload();
							parent.swal("", msg, "success");
						}else {
							parent.swal("", msg, "error");
						}
	                }
	           	});
			});
		}
		//启用/停用
		function _dealStatus(carUuid,status){
			var tip ='';
			if(status=='1'){
				tip = '确定启用吗？';
			}else if(status=='0'){
				tip = '确定停用吗？';
			}
			parent.swal({
				title: tip, 
				type: "warning",
				showCancelButton: true,
				closeOnConfirm: false,
				cancelButtonText: "取消",
				cancelButtonColor: "#ec6c62",
				confirmButtonText: "确定",
				confirmButtonColor: "#ec6c62"
				}, function() {
					$.ajax({
		                cache: true,
		                type: "POST",
		                url:'<%=path%>/vehicleInfo/dealStatus',
		                data:{
		                	carUuid:carUuid,
		                	status:status
		                },
		                async: false,
		                error: function(request) {
		                    parent.swal("", msg, "操作失败!");
		                },
		                success: function(data) {
		                	data = eval('(' + data + ')');
							var msg = data.msg;
		                    if(data.success){
		                     	location.reload();
								parent.swal("", msg, "success");
							}else {
								parent.swal("", msg, "error");
							}
		                }
		           	});
			 });
		}
</script>
</head>
<body style="font-family: '微软雅黑';padding: 0px;">
	<div id="contentDiv" style="padding:5px; width:99%;margin-left: 0px;">
 		<div style="width:100%;height:30px;border-bottom:1px solid #ADADAD;margin-bottom: 15px;">
	      	<div class="toptil">车辆信息维护
			</div>
	    </div>
		<div class="appeal_s" style="float:none;width: 100%;margin: 0px;padding: 10px 0px;">
			<form id="fm" name="fm" method="post" action="" novalidate="novalidate">
				<span style="padding-left:6px;">车牌号码：</span><input type="text"  class="input-medium" style="height: 24px;width: 160px;" name="carNo" id="carNo"/>
                 <button  type="button" class="saveButton" onclick="_queryList()">查询</button>
                 <button  type="button" class="saveButton" onclick="_addVehicle()">添加</button>
			</form>
		</div>
		<div class="row-fluid dataTables_wrapper" style="margin-top: 15px;" >
			<table id="listTable" class="table table-hover table-nomargin table-bordered usertable dataTable"
			style="width: 100%; border-spacing: 0;">
				<thead>
					<tr class="trBgd" style="background-color: #eee;text-align: center; height: 31px; border: 1px solid #ddd; white-space: nowrap; background-position: 0 -123px; line-height: 30px; font-weight: bold;">
						<th class="span5" nowrap> 序号 </th>
						<th class="span10" nowrap> 车辆名称 </th>
						<th class="span15" nowrap> 车牌号 </th>
						<th class="span10" nowrap> 车辆颜色 </th>
						<th class="span10" nowrap> 状态 </th>
						<th class="span15" nowrap> 操作 </th>
					</tr>
				</thead>
				<tbody id="list_tbody" style="font-size: 13px">
				</tbody>
			</table>
			<div class="dataTables_paginate paging_full_numbers">
				<span id="innerHtml"> </span>
			</div>
			<div id="pagination"></div>
			<div>
				<div style="height: 30px;"></div>
				<div class="clear"></div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	$(document).ready(function(){
		_reHeight();
	});
	function _reHeight(){
		var main = $(window.parent.document).find("#rightFrame");
		var mainheight = $("#contentDiv").height();
		main.height(mainheight);
	}

</script>
</html>
